/*******************************************************************************

This code file produces Table A4.

*******************************************************************************/

*** Manage settings

	run "$dir/code/modules/settings.do"
	
* Load Stata-TeX

	do "$code/modules/stata-tex.do"
	cd "$tables/estimates"
	
*** Load data

	use "$data/clean/cleaned_data.dta", clear
	
********************************************************************************
* Complete table analysis
********************************************************************************

*** LPM versus logit, Borough FEs

	reghdfe inclusionary_onsite dtaxrate_onsite, a(borough yearpermit) cl(nta)
	store_est_tpl using tableA4.csv, coef(dtaxrate_onsite) name(lpm1) all
	
	reghdfe inclusionary_onsite dtaxrate_onsite, a(nta yearpermit) cl(nta)
	store_est_tpl using tableA4.csv, coef(dtaxrate_onsite) name(lpm2) all
	
	logit inclusionary_onsite dtaxrate_onsite i.borough i.yearpermit, cl(nta)
	store_est_tpl using tableA4.csv, coef(dtaxrate_onsite) name(logit1) all
	
	margins, dydx(dtaxrate_onsite) post
	store_est_tpl using tableA4.csv, coef(dtaxrate_onsite) name(margins1) all
	
	logit inclusionary_onsite dtaxrate_onsite i.nta i.yearpermit, cl(nta)
	store_est_tpl using tableA4.csv, coef(dtaxrate_onsite) name(logit2) all
	
	margins, dydx(dtaxrate_onsite) post
	store_est_tpl using tableA4.csv, coef(dtaxrate_onsite) name(margins2) all
	
********************************************************************************
* Create table
********************************************************************************
	
	cat tableA4.csv

	cap erase "$tables/output/tableA4.tex"

	cd "$code/modules"
	capture table_from_tpl, t("$tables/templates/tableA4.tex") ///
						r("$tables/estimates/tableA4.csv") ///
						o("$tables/output/tableA4.tex") 
						
	cd "$code/modules"
	capture table_from_tpl, t("$tables/templates/tableA4.tex") ///
						r("$tables/estimates/tableA4.csv") ///
						o("$tables_overleaf/tableA4.tex") 
		
	exit
